Imports CIPF.Annotations
Namespace Annotations
  Public Class AnnotationContainerProperties
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
      MyBase.New()

      'This call is required by the Windows Form Designer.
      InitializeComponent()

      'Add any initialization after the InitializeComponent() call
    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
      If disposing Then
        If Not (components Is Nothing) Then
          components.Dispose()
        End If
      End If
      MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents pnlColor As System.Windows.Forms.Panel
    Friend WithEvents txtText As System.Windows.Forms.TextBox
    Friend WithEvents chkVisible As System.Windows.Forms.CheckBox
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents btnCancel As System.Windows.Forms.Button
    Friend WithEvents btnOk As System.Windows.Forms.Button
    Friend WithEvents txtKey As System.Windows.Forms.TextBox
    Friend WithEvents Label7 As System.Windows.Forms.Label
    Friend WithEvents polyColorDialog As System.Windows.Forms.ColorDialog
    Friend WithEvents chkRegionVisible As System.Windows.Forms.CheckBox
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
      Me.pnlColor = New System.Windows.Forms.Panel
      Me.txtText = New System.Windows.Forms.TextBox
      Me.chkVisible = New System.Windows.Forms.CheckBox
      Me.Label3 = New System.Windows.Forms.Label
      Me.Label1 = New System.Windows.Forms.Label
      Me.btnCancel = New System.Windows.Forms.Button
      Me.btnOk = New System.Windows.Forms.Button
      Me.txtKey = New System.Windows.Forms.TextBox
      Me.Label7 = New System.Windows.Forms.Label
      Me.polyColorDialog = New System.Windows.Forms.ColorDialog
      Me.chkRegionVisible = New System.Windows.Forms.CheckBox
      Me.GroupBox1 = New System.Windows.Forms.GroupBox
      Me.GroupBox1.SuspendLayout()
      Me.SuspendLayout()
      '
      'pnlColor
      '
      Me.pnlColor.BackColor = System.Drawing.Color.Red
      Me.pnlColor.Location = New System.Drawing.Point(169, 23)
      Me.pnlColor.Name = "pnlColor"
      Me.pnlColor.Size = New System.Drawing.Size(22, 21)
      Me.pnlColor.TabIndex = 37
      '
      'txtText
      '
      Me.txtText.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
      Me.txtText.Location = New System.Drawing.Point(72, 37)
      Me.txtText.Name = "txtText"
      Me.txtText.Size = New System.Drawing.Size(156, 20)
      Me.txtText.TabIndex = 36
      '
      'chkVisible
      '
      Me.chkVisible.CheckAlign = System.Drawing.ContentAlignment.MiddleRight
      Me.chkVisible.Checked = True
      Me.chkVisible.CheckState = System.Windows.Forms.CheckState.Checked
      Me.chkVisible.FlatStyle = System.Windows.Forms.FlatStyle.Flat
      Me.chkVisible.Location = New System.Drawing.Point(8, 64)
      Me.chkVisible.Name = "chkVisible"
      Me.chkVisible.Size = New System.Drawing.Size(76, 24)
      Me.chkVisible.TabIndex = 35
      Me.chkVisible.Text = "Visible"
      '
      'Label3
      '
      Me.Label3.Location = New System.Drawing.Point(7, 39)
      Me.Label3.Name = "Label3"
      Me.Label3.Size = New System.Drawing.Size(55, 16)
      Me.Label3.TabIndex = 33
      Me.Label3.Text = "Text"
      '
      'Label1
      '
      Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.Label1.Location = New System.Drawing.Point(120, 24)
      Me.Label1.Name = "Label1"
      Me.Label1.Size = New System.Drawing.Size(42, 18)
      Me.Label1.TabIndex = 32
      Me.Label1.Text = "Color"
      '
      'btnCancel
      '
      Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
      Me.btnCancel.Location = New System.Drawing.Point(131, 167)
      Me.btnCancel.Name = "btnCancel"
      Me.btnCancel.Size = New System.Drawing.Size(64, 25)
      Me.btnCancel.TabIndex = 40
      Me.btnCancel.Text = "Cancel"
      '
      'btnOk
      '
      Me.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK
      Me.btnOk.Location = New System.Drawing.Point(38, 167)
      Me.btnOk.Name = "btnOk"
      Me.btnOk.Size = New System.Drawing.Size(64, 25)
      Me.btnOk.TabIndex = 39
      Me.btnOk.Text = "Ok"
      '
      'txtKey
      '
      Me.txtKey.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
      Me.txtKey.Enabled = False
      Me.txtKey.Location = New System.Drawing.Point(72, 10)
      Me.txtKey.Name = "txtKey"
      Me.txtKey.Size = New System.Drawing.Size(156, 20)
      Me.txtKey.TabIndex = 46
      '
      'Label7
      '
      Me.Label7.Location = New System.Drawing.Point(8, 11)
      Me.Label7.Name = "Label7"
      Me.Label7.Size = New System.Drawing.Size(55, 16)
      Me.Label7.TabIndex = 45
      Me.Label7.Text = "Name"
      '
      'polyColorDialog
      '
      Me.polyColorDialog.AnyColor = True
      '
      'chkRegionVisible
      '
      Me.chkRegionVisible.CheckAlign = System.Drawing.ContentAlignment.MiddleRight
      Me.chkRegionVisible.Checked = True
      Me.chkRegionVisible.CheckState = System.Windows.Forms.CheckState.Checked
      Me.chkRegionVisible.FlatStyle = System.Windows.Forms.FlatStyle.Flat
      Me.chkRegionVisible.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.chkRegionVisible.Location = New System.Drawing.Point(10, 21)
      Me.chkRegionVisible.Name = "chkRegionVisible"
      Me.chkRegionVisible.Size = New System.Drawing.Size(72, 24)
      Me.chkRegionVisible.TabIndex = 48
      Me.chkRegionVisible.Text = "Visible"
      '
      'GroupBox1
      '
      Me.GroupBox1.Controls.Add(Me.chkRegionVisible)
      Me.GroupBox1.Controls.Add(Me.pnlColor)
      Me.GroupBox1.Controls.Add(Me.Label1)
      Me.GroupBox1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
      Me.GroupBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
      Me.GroupBox1.Location = New System.Drawing.Point(2, 94)
      Me.GroupBox1.Name = "GroupBox1"
      Me.GroupBox1.Size = New System.Drawing.Size(228, 59)
      Me.GroupBox1.TabIndex = 49
      Me.GroupBox1.TabStop = False
      Me.GroupBox1.Text = "Region"
      '
      'DrawablePolygonContainerProperties
      '
      Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
      Me.ClientSize = New System.Drawing.Size(233, 202)
      Me.Controls.Add(Me.GroupBox1)
      Me.Controls.Add(Me.txtKey)
      Me.Controls.Add(Me.txtText)
      Me.Controls.Add(Me.Label7)
      Me.Controls.Add(Me.btnCancel)
      Me.Controls.Add(Me.btnOk)
      Me.Controls.Add(Me.chkVisible)
      Me.Controls.Add(Me.Label3)
      Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
      Me.Name = "DrawablePolygonContainerProperties"
      Me.Text = "Annotation set properties"
      Me.GroupBox1.ResumeLayout(False)
      Me.ResumeLayout(False)
      Me.PerformLayout()

    End Sub

#End Region

    Public Sub SetDialogNewProperties()
      txtKey.Enabled = True
    End Sub

    Public Sub SetDialogProperties(ByVal annContainer As AnnotationContainer)
      'Set all the dialog properties using the annotation container values
      txtKey.Text = annContainer.Key
      txtText.Text = annContainer.Text
      chkVisible.Checked = annContainer.Visible
      pnlColor.BackColor = annContainer.Color
      chkRegionVisible.Checked = annContainer.RegionVisible
    End Sub

    Public Overloads Sub SetAnnotationContainerProperties(ByVal annContainer As AnnotationContainer)
      'Set all the properties using the dialog values
      annContainer.Color = pnlColor.BackColor
      annContainer.Text = txtText.Text
      annContainer.Visible = chkVisible.Checked
      annContainer.RegionVisible = chkRegionVisible.Checked
    End Sub

    Public Overloads Function SetAnnotationContainerProperties(ByVal container As Annotations) As AnnotationContainer
      'Use when creating a new container
      Dim strKey As String
      If txtKey.TextLength > 0 Then
        strKey = txtKey.Text
      Else
        Dim iID As Integer = 1
        Do While container.ContainsKey("Container " & iID)
          iID = iID + 1
        Loop
        strKey = "Container " & iID
      End If
      Dim oAnnCon As New AnnotationContainer
      container.Add(strKey, oAnnCon)
      SetAnnotationContainerProperties(oAnnCon)
      Return oAnnCon
    End Function

    Private Sub txtKey_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtKey.TextChanged
      'Key is used as text
      txtText.Text = txtKey.Text
    End Sub

    Private Sub chkRegionVisible_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkRegionVisible.CheckedChanged
      Me.pnlColor.Enabled = chkRegionVisible.Checked
    End Sub

    Private Sub pnlColor_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles pnlColor.Click
      If polyColorDialog.ShowDialog(Me) = DialogResult.OK Then
        pnlColor.BackColor = polyColorDialog.Color
      End If
    End Sub

  End Class
End Namespace
